﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Windows.Documents;
using Abhiruchi_Phase1;
using System.Data;

namespace Abhiruchi_Phase1.BAL_DAL.HRM_DAL
{
    public class PE_CE_MainWindowDAL
    {
        private static string connectionString = App.ConnectionString;
        public static List<string> lstEid = new List<string>();
        public static List<string> lstEname = new List<string>();
        public static List<string> lst = new List<string>();
        public PE_CE_MainWindowDAL()
        {
            lstEid.Clear();
        }

        public static List<string> GetEmployeeMasterEmployeeList()
        {
            lst.Clear();

            SqlConnection mycon = new SqlConnection(connectionString);
            SqlCommand mycom = new SqlCommand("SP_Get_Set_HRM_EmployeeMaster", mycon);
            mycom.CommandType = CommandType.StoredProcedure;
            mycom.Parameters.AddWithValue("@ptype", 1);
            SqlDataAdapter myAdp = new SqlDataAdapter(mycom);
            DataTable myDt = new DataTable();
            myAdp.Fill(myDt);
            if (myDt.Rows.Count > 0)
            {
                for (int i = 0; i < myDt.Rows.Count; i++)
                {
                    lst.Add(myDt.Rows[i][0].ToString());
                    lst.Add(myDt.Rows[i][1].ToString());
                }
            }

            return lst;
        }

        public static DataTable GetEmployeesInfoTable()
        {
            SqlConnection mycon = new SqlConnection(connectionString);
            SqlCommand mycom = new SqlCommand("SP_Get_Set_HRM_EmployeeMaster", mycon);
            mycom.CommandType = CommandType.StoredProcedure;
            mycom.Parameters.AddWithValue("@ptype", 1);
            SqlDataAdapter myAdp = new SqlDataAdapter(mycom);
            DataTable myDt = new DataTable();
            myAdp.Fill(myDt);

            return myDt;
        }

        public static DataTable GetEmployeesInfoWithNames(string name)
        {
            SqlConnection mycon = new SqlConnection(connectionString);
            SqlCommand mycom = new SqlCommand("SP_Get_Set_HRM_EmployeeMaster", mycon);
            mycom.CommandType = CommandType.StoredProcedure;
            mycom.Parameters.AddWithValue("@Ename", name);
            mycom.Parameters.AddWithValue("@ptype", 5);
            SqlDataAdapter myAdp = new SqlDataAdapter(mycom);
            DataTable myDt = new DataTable();
            myAdp.Fill(myDt);

            return myDt;
        }
    }
}
